
package com.epam.android.training.task.test;

import android.os.Parcel;
import android.os.Parcelable;

import java.util.ArrayList;

/**
 * @author pavel_busko
 * 
 * This class reflects test question entity.
 */
public class Question implements Parcelable {

    private String text;

    private ArrayList<String> answers = new ArrayList<String>();

    private Integer correct;

    public Question() {}

    public Question(Parcel in) {
        // this(); // call constructor to initialize the ArrayList
        this.text = in.readString();
        this.correct = in.readInt();
        in.readStringList(answers);
    }

    public static final Parcelable.Creator<Question> CREATOR = new Parcelable.Creator<Question>() {

        @Override
        public Question createFromParcel(Parcel source) {
            return new Question(source);
        }

        @Override
        public Question[] newArray(int size) {
            return new Question[size];
        }
    };

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(text);
        dest.writeInt(correct);
        dest.writeStringList(answers);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    /**
     * @return list of answers
     */
    public ArrayList<String> getAnswers() {
        return answers;
    }

    public void setAnswers(ArrayList<String> answers) {
        this.answers = answers;
    }

    /**
     * @return correct answer index in {@link #getAnswers()}
     */
    public Integer getCorrect() {
        return correct;
    }

    public void setCorrect(Integer correct) {
        this.correct = correct;
    }
}
